<!DOCTYPE html>
<html lang="en">
<head>
    <script src="http://timemejs.com/timeme.min.js"></script>
    <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>

    <meta charset="UTF-8">
    <title>index</title>

    <script type="text/javascript">

        $(window).on("beforeunload", function() {
            var timeSpentOnPage = TimeMe.getTimeOnCurrentPageInSeconds();
            var arr = { user: "liuyang", pageUrl: "/index.html", pageTitle: "index", viewTime: timeSpentOnPage};
            $.ajax({
                url: '/archetype/statistic/pageViewTime',
                type: 'POST',
                data: JSON.stringify(arr),
                contentType: 'application/json; charset=utf-8',
                dataType: 'json',
                async: true,
                success: function(r) {
                    console.log(r);
                }
            });
        })

    </script>
</head>
<body>
aaa

<script type="text/javascript">
    TimeMe.initialize({
        currentPageName: "index-page", // page name
        idleTimeoutInSeconds: 100 // time before user considered idle
    });
</script>


</body>
</html>